package be.shoktan.tutorial.model;

import org.apache.commons.lang.builder.CompareToBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.log4j.Logger;

public class User {
	private static final Logger LOG = Logger.getLogger(User.class);
	{
		if(LOG.isTraceEnabled())LOG.trace("creating a new User");
	}
	
	private String username;
	private String password;
	private String portfolioName;
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		if(LOG.isTraceEnabled())LOG.trace("setUsername("+username+")");
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getPortfolioName() {
		return portfolioName;
	}
	public void setPortfolioName(String portfolioName) {
		this.portfolioName = portfolioName;
	}
	
	public int compareTo(Object o) {
	     User user = (User) o;
	     return new CompareToBuilder()
	       .append(this.username, user.username)
	       .append(this.portfolioName, user.portfolioName)
	       .append(this.password, user.password)
	       .toComparison();
	}
	
	public boolean equals(Object obj) {
		return EqualsBuilder.reflectionEquals(this, obj);
	}
	 
	public int hashCode() {
		return HashCodeBuilder.reflectionHashCode(this);
	}
}